<?php

namespace App\Service;

use App\Constants\ErrorCode;
use App\Model\Channel;
use App\Model\LinkChannel;
use App\Model\LinkFile;
use App\Model\LinkIndustry;
use App\Model\Product;
use App\Model\ProductSpecKey;
use App\Model\ProductSpecValue;
use Hyperf\DbConnection\Db;
use Hyperf\Snowflake\IdGeneratorInterface;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerInterface;
use Hyperf\Di\Annotation\Inject;
use Psr\Http\Message\ResponseInterface;

class LinkFileService extends BaseService
{

    //    关联文件插入
    public function  link_file_insert(array  $files,$product_id,$type=2)
    {
        $this->deleteByWhere([
            'link_id'=>$product_id,
            'type'=>$type,
            ]);
        //        文件
        foreach ($files as $v){
                $this->insertAndGetId(
                [
                    'fileinfo_id'=>$v,
                    'link_id'=>$product_id,
                    'type'=>$type,
                ]);
        }
        return true;
    }

}